﻿
using Panuon.UI.Silver;
using ProjectModel;
using System;
using System.Windows;
using System.Windows.Navigation;
using ViewModel;

namespace DemoWPF
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : WindowX
    {
        public MainWindow()
        {
            InitializeComponent();
            this.DataContext = new MainViewModel(App.dicConfig);
        }

        private void TvMenu_SelectionChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
        {
            if (this.MyFrame.NavigationService != null)
            {
                this.MyFrame.NavigationService.Navigated += NavServiceOnNavigated;
                this.MyFrame.Navigate(new Uri(((TreeViewItemModel)e.NewValue).StrUrl, UriKind.Relative));
            }

           
        }

        private void NavServiceOnNavigated(object sender, NavigationEventArgs e)
        {
            this.MyFrame.NavigationService.RemoveBackEntry();
            this.MyFrame.NavigationService.Navigated -= NavServiceOnNavigated;
        }
    }
}
